﻿namespace AgileBoard.Infrastructure.Data.Repositories
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using Domain;
    using Domain.DataInterfaces;
    using SharpArch.Data.NHibernate;

    public class UserRepository : Repository<User>, IUserRepository
    {
 
        public IList<User> FindByProject(Guid projectID)
        {
            return Session.CreateQuery("from User where ProjectID = :projectID")
                .SetParameter("projectID", projectID)
                .List<User>();
        }

        public User FindByName(string userName)
        {
            IList User = Session.CreateQuery("from User where UserName = :UserName")
                .SetParameter("UserName", userName)
                .List();

            if (User.Count > 0) return User[0] as User;
            else return null;
        }
    }
}